//package com.coding.beautiful.config;
//
//import org.springframework.beans.factory.InitializingBean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
//import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
//import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author : champ
// * @version V1.0
// * @Description:
// * @date 2021年08月15日 16:28
// */
//@Configuration
//public class InitializingAdvice implements InitializingBean {
//
//    @Resource
//    private RequestMappingHandlerAdapter adapter;
//
//    @Override
//    public void afterPropertiesSet() {
//        List<HandlerMethodReturnValueHandler> returnValueHandlers = adapter.getReturnValueHandlers();
//        List<HandlerMethodReturnValueHandler> newHandlers = new ArrayList<>( returnValueHandlers );
//        extracted(newHandlers);
//
//        adapter.setReturnValueHandlers( newHandlers );
//    }
//
//    private void extracted(List<HandlerMethodReturnValueHandler> newHandlers) {
//        for ( HandlerMethodReturnValueHandler handler: newHandlers) {
//            if ( handler instanceof RequestResponseBodyMethodProcessor) {
//                WrapReturunValueHandler decorator = new WrapReturunValueHandler( (RequestResponseBodyMethodProcessor) handler );
//                int index = newHandlers.indexOf( handler );
//                newHandlers.set( index, decorator );
//                break;
//            }
//        }
//    }
//
//}
